﻿Imports System.Windows.Forms

Public Class Damage

    Private _character As Character
    Private _original As Character
    Private _damage As Boolean

    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.ApplyToCharacter = New Character
        Me.IsDamage = False
    End Sub

    Sub New(ByVal item As Character, ByVal isdamage As Boolean)
        InitializeComponent()
        Me.ApplyToCharacter = item
        Me.IsDamage = isdamage
    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        If Me.BodyTextBox.Text > 0 Then
            If IsDamage Then
                Me.ApplyToCharacter.CurrentBody -= CInt(Me.BodyTextBox.Text)
            Else
                Me.ApplyToCharacter.CurrentBody += CInt(Me.BodyTextBox.Text)
            End If
        End If

        If Me.StunTextBox.Text > 0 Then
            If IsDamage Then
                Me.ApplyToCharacter.CurrentStun -= CInt(Me.StunTextBox.Text)
            Else
                Me.ApplyToCharacter.CurrentStun += CInt(Me.StunTextBox.Text)
            End If
        End If

        MainForm.AllCharacters.Edit(Me.OriginalCharacter, Me.ApplyToCharacter)
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Public Property ApplyToCharacter() As Character
        Get
            Return _character
        End Get
        Set(ByVal value As Character)
            _character = value
            _original = value
        End Set
    End Property

    Public Property IsDamage() As Boolean
        Get
            Return _damage
        End Get
        Set(ByVal value As Boolean)
            _damage = value
        End Set
    End Property

    Public ReadOnly Property OriginalCharacter() As Character
        Get
            Return _original
        End Get
    End Property

    Private Sub RollButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RollButton.Click

    End Sub
End Class
